import manageDao from "../dao/manage";
import type {Manage} from "../types";
import {getUuid,getCurrentTime,logger} from "../utils";

export async function queryList(type: number) {
  try {
    return await manageDao.queryList(type);
  } catch (error) {
    logger(error);
  }
}

export async function insert(data:Manage){
  try {
    const rank = await manageDao.getRank()
    return await manageDao.insert({ ...data, id: getUuid(), source: 0 ,createTime:getCurrentTime(),rank});
  } catch (error) {
    logger(error);
  }
}

export async function deleteById(id){
  try {
    return await manageDao.deleteById(id);
  } catch (error) {

    logger(error);
  }
}

export async function update(data :Manage){
  try {
    return await manageDao.update(data);
  } catch (error) {
    logger(error);
  }
}
export async function queryById(id: number) {
  try {
    return await manageDao.queryById(id);
  } catch (error) {
    logger(error);
  }
}
export default {
  queryList,
  insert,
  deleteById,
  update,
  queryById,
};
